<%_
    var instanceType = (dto == 'mapstruct') ? entityClass + 'DTO' : entityClass;
    var instanceName = (dto == 'mapstruct') ? entityInstance + 'DTO' : entityInstance;
    var mapper = entityInstance + 'Mapper';
    var entityToDtoReference = mapper + '::'+ entityInstance +'To' + entityClass + 'DTO';
    var entityListToDtoListReference = mapper + '.'+ entityInstancePlural +'To' + entityClass + 'DTOs';
    if (dto == 'mapstruct') { %>
    @Transactional(readOnly = true)<% } if (pagination == 'no') { %>
    public List<<%= instanceType %>> search<%= entityClassPlural %>(@RequestParam String query) {
        log.debug("REST request to search <%= entityClassPlural %> for query {}", query);<%- include('search_stream_template', {viaService: viaService}); -%>
    <% } if (pagination != 'no') { %>
    public ResponseEntity<List<<%= instanceType %>>> search<%= entityClassPlural %>(@RequestParam String query, Pageable pageable)
        throws URISyntaxException {
        log.debug("REST request to search for a page of <%= entityClassPlural %> for query {}", query);<% if (viaService) { %>
        Page<<%= entityClass %>> page = <%= entityInstance %>Service.search(query, pageable);<% } else { %>
        Page<<%= entityClass %>> page = <%= entityInstance %>SearchRepository.search(queryStringQuery(query), pageable);<% } %>
        HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/<%= entityApiUrl %>");
        return new ResponseEntity<>(<% if (dto == 'mapstruct') { %><%= entityListToDtoListReference %>(page.getContent())<% } else { %>page.getContent()<% } %>, headers, HttpStatus.OK);
    <% } -%>
}